﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using ZFSDomain.Common.UserControls;
using ZFSDomain.Interface.Base;
using ZFSDomain.Interface.User;
using ZFSDomain.SysModule;

namespace ZFSDomain.ViewDialog.User
{

    /// <summary>
    /// 添加用户
    /// </summary>
    public class SearchUserDlg : ISelectUserDialog
    {
        private SearchUserWindow view;

        public void BindViewModel<TViewModel>(TViewModel viewModel) where TViewModel : ViewModelBase
        {
            this.GetDialog().DataContext = viewModel;
        }

        public void Close()
        {
            this.GetDialog().Close();
        }

        public bool? ShowDialog()
        {
            var dialog = this.GetDialog();
            dialog.ShowDialog();
            return (dialog.DataContext as BaseDialogOperation).Result;
        }

        private SearchUserWindow GetDialog()
        {
            if (view == null)
            {
                view = new SearchUserWindow();
            }
            return view;
        }
    }
}
